<template>
    <view class="gjl-view">
        <view class="add-ul">
            <view class="add-li index1" @click="saoma">
                <view class="left">
                    <view class="icon-box">
                        <mIcon type="saoma" size="16" color="#fff"></mIcon>
                    </view>
                    <view class="text">
                        扫码添加
                    </view>
                </view>
                <view class="right">
                    <mIcon type="arrRight" color="#999" size="14"></mIcon>
                </view>
            </view>
            <view class="add-li index2" @click="$routerTo({path: '/pagesMine/bookstore/search',query:{bookstoreSortId:pos.bookstoreSortId || ''}})">
                <view class="left">
                    <view class="icon-box">
                        <mIcon type="jiansuo" size="16" color="#fff"></mIcon>
                    </view>
                    <view class="text">
                        搜索添加
                    </view>
                </view>
                <view class="right">
                    <mIcon type="arrRight" color="#999" size="14"></mIcon>
                </view>
            </view>
            <view class="add-li index3" @click="$routerTo({path: '/pagesMine/bookstore/addForm',query:{bookstoreSortId:pos.bookstoreSortId || ''}})">
                <view class="left">
                    <view class="icon-box">
                        <mIcon type="dianji" size="16" color="#fff"></mIcon>
                    </view>
                    <view class="text">
                        手动添加
                    </view>
                </view>
                <view class="right">
                    <mIcon type="arrRight" color="#999" size="14"></mIcon>
                </view>
            </view>
            <view class="add-li index4" v-if="pos.type == 1" @click="$routerTo({path: '/pagesMine/bookstore/index',query:{type: 1,bookstoreSortId: pos.bookstoreSortId || '',addType: 1}})">
                <view class="left">
                    <view class="icon-box">
                        <mIcon type="shuji" size="16" color="#fff"></mIcon>
                    </view>
                    <view class="text">
                        从书屋中添加
                    </view>
                </view>
                <view class="right">
                    <mIcon type="arrRight" color="#999" size="14"></mIcon>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import service from "@/service";
    export default {
        data(){
            return{
                pos:{}
            }
        },
        onLoad(res) {
            this.pos = res
        },
        methods:{
            saoma(){
                uni.scanCode({
                    success: (res) => {
                        let obj = {sibn:res.result}
                        if(this.pos.bookstoreSortId){
                            obj.bookstoreSortId = this.pos.bookstoreSortId
                        }
                        service.mineService.BookstoreAddSIBNBookstore({
                            data: {...obj},
                            success: res => {
                                uni.showToast({
                                    title: '添加成功',
                                    icon: 'none'
                                })
                                // uni.navigateBack({
                                //     delta:1
                                // })
                            },
                            fail: ()=>{
                                
                            },
                            complete: () => {
                                
                            },
                        });
                        // console.log('条码类型：' + res.scanType);
                        // console.log('条码内容：' + res.result);
                    },
                    fail: function(){
                        uni.showModal({
                            title: '提示',
                            content: `扫码失败，请重试`
                        })
                    }
                });
            }
        }
    }
</script>

<style scoped lang="scss">
    page{
        height: 100%;
    }
    .gjl-view{
        min-height: 100%;
        overflow: hidden;
        background:rgba(249,249,249,1);
        .add-ul{
            .add-li.index4{
                .left{
                    .icon-box{
                        background:rgba(252,44,51,1);
                    }
                }
            }
            .add-li.index3{
                .left{
                    .icon-box{
                        background:rgba(255,180,68,1);
                    }
                }
            }
            .add-li.index2{
                .left{
                    .icon-box{
                        background:rgba(65,218,176,1);
                    }
                }
                
            }
            .add-li{
                padding: 28rpx 50rpx 28rpx 57rpx;
                background:rgba(255,255,255,1);
                margin-top: 20rpx;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .left{
                    display: flex;
                    align-items: center;
                    .icon-box{
                        background:rgba(66,135,255,1);
                        height: 65rpx;
                        width: 65rpx;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 20rpx;
                    }
                    .text{
                        margin-left: 20rpx;
                        font-size:28rpx;
                        font-weight:400;
                        color:rgba(51,51,51,1);
                    }
                }
                .right{
                    
                }
            }
        }
    }
</style>